<?php
/**
 * Created by PhpStorm.
 * User: lee
 * Date: 12/7/18
 * Time: 4:09 PM
 */

$domainName = 'ws.jinse.com';
$port = 443;
$ssl = true;
$cli = new \Swoole\Http\Client($domainName, $port, $ssl);
$cli->set(['websocket_mask' => true]);
//$cli->setHeaders(array('User-Agent' => 'swoole-http-client',
//    'Host' =>  $domainName,
//    'Accept' => 'text/html,application/xhtml+xml,application/xml',
//    'Accept-Encoding' => 'gzip',
//));
//$cli->setCookies(array('test' => 'value'));
$cli->on('message', function ($_cli, $frame) {
    echo '123123';
    echo $frame;
});

$cli->upgrade('/ws', function ($cli) {
    echo $cli->body;
    $cli->push('{"event":"jinse","action":"sub","channel":"jinse_tick_update"}');
});